﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BasicSample
{
    public class GSTCalculator
    {
        private static GSTCalculator _instance;

        static GSTCalculator()
        {
            _instance = new GSTCalculator();
        }

        public static GSTCalculator Instance
        {
            get
            {
                return _instance;

            }
        }

        private IDictionary<string, double> gstAmounts
            = new Dictionary<string, double>();


        public void RegisterGST(string productName, double amount)
        {
            gstAmounts.Add(productName, amount);
        }

        public double GSTAmount(string product, double cost)
        {
            return gstAmounts.ContainsKey(product) ?
                gstAmounts[product] * cost
                : 0;
        }

        public void Clear()
        {
            gstAmounts.Clear();
        }
    }
}
